package com.woniuxy.service.impl;

import com.woniuxy.entity.BizServicePackage;
import com.woniuxy.mapper.BizServicePackageMapper;
import com.woniuxy.service.BizServicePackageService;
import com.woniuxy.util.ResponseEnum;
import com.woniuxy.util.ResponseUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 业务服务包服务实现类
 * 实现业务服务包相关的业务逻辑
 */
@Service
public class BizServicePackageServiceImpl implements BizServicePackageService {
    @Resource
    private BizServicePackageMapper bizServicePackageMapper;

    /**
     * 根据组织ID查询服务包
     * @param orgId 组织ID
     * @return 返回指定组织的服务包信息
     */
    @Override
    public ResponseUtil findServicePackage(Integer orgId) {
        List<BizServicePackage> servicePackages = bizServicePackageMapper.findServicePackage(orgId);
        return servicePackages.isEmpty() ? ResponseUtil.get(ResponseEnum.FAIL)
                : ResponseUtil.get(ResponseEnum.OK,servicePackages);
    }

    /**
     * 根据ID查询服务包详情
     * @param id 服务包ID
     * @return 返回指定ID的服务包详情
     */
    @Override
    public ResponseUtil findServicePackageById(Integer id) {
        BizServicePackage servicePackageById = bizServicePackageMapper.findServicePackageById(id);
        return servicePackageById == null ? ResponseUtil.get(ResponseEnum.FAIL)
                : ResponseUtil.get(ResponseEnum.OK,servicePackageById);
    }
}
